package com.hkbigdata.sybx.mapper;


import com.hkbigdata.sybx.bean.ServiceEvaluation;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author liuanbo
 * @creat 2025-05-31-22:06
 * @see 2194550857@qq.com
 */
@Mapper
public interface ServiceEvaluationMapper {
    @Insert("insert into service_reviews( user_id,star_rating, content) " +
            "values (#{userId}, #{starRating}, #{content})")
    int insertServiceEvaluation(ServiceEvaluation serviceEvaluation);

    @Select("SELECT * FROM service_reviews WHERE user_id = #{userId}")
    @Results({
            @Result(column = "user_id", property = "userId"),
            @Result(column = "star_rating", property = "starRating"),
            @Result(column = "content", property = "content"),
            @Result(column = "create_time", property = "createTime")
    })
    ServiceEvaluation selectServiceEvaluation(@Param("userId") Long userId);

    @Select("select star_rating as starRating, content as content, create_time as createTime, user_id as userId from service_reviews")
    List<ServiceEvaluation> ServiceEvaluationsEvaluation();
    // 添加删除方法：根据用户ID删除
    @Delete("DELETE FROM service_reviews WHERE user_id = #{userId}")
    int deleteByUserId(@Param("userId") String userId);
}
